package com.zang.concurrent.collections.blockingqueue;

import java.util.concurrent.BlockingQueue;

/**
 * @author Zhang Qiang
 * @Date 2019/9/6 17:17
 */
public class Producer implements Runnable {
    protected BlockingQueue queue = null;
    public Producer(BlockingQueue queue){
        this.queue = queue;
    }
    /**
     * 放入数据
     *
     * @return
     */
    @Override
    public void run() {
        int a = 0;
        try {
            while (true){
                a++;
                queue.put( " a = " + a);
                Thread.sleep(500);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
